<?php 
	require 'libraries/AddSampleLib.php';
	require 'libraries/UserLibrary.php';
	session_start();
	checkSessionVariable("administrator", "AdministratorHomepage.php", NULL);
	
	$SamplingDate =  $_POST['samplingdate'];
	$SamplingSig =  $_POST['samplesignature'];
	$MainTypes = $_POST['mainTypes'];
	$AnalysisRequired =  $_POST['analysisreq'];
	$SampleReceive = $_POST['samplereceive'];
	$Remarks =  $_POST['remarks'];

	/*Get the number of inputs*/
	$counter = $_POST["counter"];
	echo $counter."</br>";
	echo count($Remarks)."</br>";
	for($i = 0; $i < $counter; $i++){
		$insertSamDate;
		$insertSamSig;
		$insertMainTypes;
		$insertAnaReq;
		$insertDateSub;
		$insertSamSub;
		$insertRem;
		
		if(isset($SamplingDate[$i]) && $SamplingDate[$i] != ""){
			$insertSamDate = $SamplingDate[$i];
		}else {
		}
		
		if(isset($SamplingSig[$i]) && $SamplingSig[$i] != ""){
			$insertSamSig = $SamplingSig[$i];
		}else {
		}
		
		if(isset($MainTypes[$i]) && $MainTypes[$i] != ""){
			$insertMainTypes = $MainTypes[$i];			
		}else {
		}
		
		if(isset($AnalysisRequired[$i]) && $AnalysisRequired[$i] != ""){
			$insertAnaReq = $AnalysisRequired[$i];
		}else {
		}

		if(isset($SampleReceive[$i]) && ($SampleReceive[$i]) != "" ){
			$insertSamRec = $SampleReceive[$i];
			echo "|".$SampleReceive[$i]."|</br>";	
		}else {
			echo "i dont have a value at SAMPLE RECEIVE: $i </br>";
		}
	
		if(isset($Remarks[$i]) && ($Remarks[$i] != "")){
			$insertRem = $Remarks[$i];
			echo count($Remarks[$i]);
			echo ($Remarks[$i] == "");
			echo "|".$Remarks[$i]."|</br>";
		}else {
			$insertRem = " ";
		}
	
		$create = InsertNewSample($_SESSION['caslnum'], ($i + 1), 
				$insertSamDate,	$insertSamSig ,$insertMainTypes,
				$_SESSION['name'], $insertRem, "casl", "localhost", 
				"createanalysis", "createanalysis");
		
		$insertSamDate = "";
		$insertSamSig = "";
		$insertMainTypes = "";
		$insertRem = "";
	
	}
	
	if($create == TRUE){
	}else{
	}
?>